<template>
  <div>
    <h1>还没分班的有</h1>
    <table>
      <tr>
        <td>姓名</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in stu">
        <td>{{ i.name }}</td>
        <td>
          <button @click="putstu(i.id)">加入班级</button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "nostu",
  data() {
    return {
      stu: [],
      tea: localStorage.getItem('userid')

    }
  },
  methods: {
    get_stu() {
      this.$axios.get('logintea/')
        .then(res => {
          this.stu = res.data.list
        })
    },
    putstu(id) {
      this.$axios.put('logintea/', {'tea': this.tea, 'id': id})
        .then(res => {
          if (res.data.code == 200) {
            alert('加入成功')
            this.get_stu()
          }
        })
    }
  },
  mounted() {
    this.get_stu()
  }
}
</script>

<style scoped>

</style>
